package com.xxl.job.admin.core.model;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * xxl-job log, used to track trigger process
 * @author xuxueli  2015-12-19 23:19:09
 */
@Entity
@Table(name = "IISP_BATCH_JOB_LOG")
@NamedQueries({
	@NamedQuery(name = JobLog.COUNT_BY_HANDLE_CODE, query = "select count(jl) from JobLog jl where jl.handleCode = :handleCode"),
	@NamedQuery(name = JobLog.COUNT_BY_HANDLE_CODE_TIME, query = " select jl.triggerTime, COUNT(jl.id) as triggerCount from JobLog jl where jl.triggerTime >= :from and jl.triggerTime <= :to and jl.handleCode like :handleCode group by jl.triggerTime")
})
public class JobLog {
	public final static String COUNT_BY_HANDLE_CODE = "countByHandleCode";
	public final static String COUNT_BY_HANDLE_CODE_TIME = "countByHandleCodeTime";
		
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	private Long id;
	
	// job info
	private Long jobGroup;
	private Long jobId;

	// glueType
	private String glueType;

	// execute info
	private String executorAddress;
	private String executorHandler;
	private String executorParam;
	
	// trigger info
	@Temporal(TemporalType.TIMESTAMP)
	private Date triggerTime;
	private int triggerCode;
	private String triggerMsg;
	
	// handle info
	@Temporal(TemporalType.TIMESTAMP)
	private Date handleTime;
	private String handleCode;
	private String handleMsg;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getJobGroup() {
		return jobGroup;
	}

	public void setJobGroup(Long jobGroup) {
		this.jobGroup = jobGroup;
	}

	public Long getJobId() {
		return jobId;
	}

	public void setJobId(Long jobId) {
		this.jobId = jobId;
	}

	public String getGlueType() {
		return glueType;
	}

	public void setGlueType(String glueType) {
		this.glueType = glueType;
	}

	public String getExecutorAddress() {
		return executorAddress;
	}

	public void setExecutorAddress(String executorAddress) {
		this.executorAddress = executorAddress;
	}

	public String getExecutorHandler() {
		return executorHandler;
	}

	public void setExecutorHandler(String executorHandler) {
		this.executorHandler = executorHandler;
	}

	public String getExecutorParam() {
		return executorParam;
	}

	public void setExecutorParam(String executorParam) {
		this.executorParam = executorParam;
	}

	public Date getTriggerTime() {
		return triggerTime;
	}

	public void setTriggerTime(Date triggerTime) {
		this.triggerTime = triggerTime;
	}

	public int getTriggerCode() {
		return triggerCode;
	}

	public void setTriggerCode(int triggerCode) {
		this.triggerCode = triggerCode;
	}

	public String getTriggerMsg() {
		return triggerMsg;
	}

	public void setTriggerMsg(String triggerMsg) {
		this.triggerMsg = triggerMsg;
	}

	public Date getHandleTime() {
		return handleTime;
	}

	public void setHandleTime(Date handleTime) {
		this.handleTime = handleTime;
	}

	public String getHandleCode() {
		return handleCode;
	}

	public void setHandleCode(String handleCode) {
		this.handleCode = handleCode;
	}

	public String getHandleMsg() {
		return handleMsg;
	}

	public void setHandleMsg(String handleMsg) {
		this.handleMsg = handleMsg;
	}
}
